Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(open_graph): locale must in language_TERRITORY format #3808

Merged
merged 4 commits into from
Nov 4, 2019

Conversation

curbengh
Copy link
Contributor

@curbengh curbengh commented Oct 27, 2019

What does it do?

Recently tested hexo.io against facebook linter. Apparently, the value for "og:locale" must be in language_TERRITORY format, so "en" is invalid. Here is a list of valid values.

If og:locale is not specified, fb defaults to "en_US".

(The following note is only applicable if you're not using en-US locale. It's optional for en-US users.)

If the language value (regardless from config or front matter) is not in language-TERRITORY format, "og:locale" will not be added.

If the language value in _config is just two characters (e.g. "en", "fr"), then you need to append territory value, e.g. "en-GB", "fr-CA". you also need to update the filename of the language file (e.g. "en.yml" -> "en-GB.yml") of your theme.

Alternatively, you could also set <%- open_graph({language: 'en-GB'}) %> in your theme layout.

How to test

git clone -b ogp-locale https://github.com/curbengh/hexo.git
cd hexo
npm install
npm test

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@coveralls
Copy link

coveralls commented Oct 27, 2019

Coverage Status

Coverage decreased (-0.1%) to 97.144% when pulling 5751b12 on curbengh:ogp-locale into 71d91af on hexojs:master.

@curbengh curbengh changed the title fix(open_graph): do not add og:locale if lang is en fix(open_graph): locale must in language_TERRITORY format Oct 27, 2019
@curbengh curbengh requested a review from a team October 27, 2019 03:52
@curbengh curbengh added this to the v4.1.0 milestone Oct 28, 2019
BREAKING CHANGE: og:locale won't be added if language value is not in 'language-territory' format
@curbengh curbengh requested review from yoshinorin and a team November 2, 2019 05:39
SukkaW
SukkaW previously approved these changes Nov 2, 2019
@curbengh
Copy link
Contributor Author

curbengh commented Nov 2, 2019

Removed i/"ignore case" regex flag since language variable is always derived from language variable, so not only the flag is unnecessary, it's actually safer to match case (for this purpose).

@curbengh curbengh requested a review from SukkaW November 2, 2019 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants